package com.hospital.hospital.service.impl;

import com.hospital.hospital.bean.User;
import com.hospital.hospital.mapper.UserMappper;
import com.hospital.hospital.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author xfm
 * @create 2021/9/2
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMappper userMappper;
    @Override
    public void regist(User user) throws Exception {
        User user1 = userMappper.queryByIdCard(user.getIdCard());
        if(user1!=null){
            throw new Exception("用户已存在");
        }else{
            userMappper.insert(user);
        }
    }


    @Override
    public User login(String idCard) throws Exception {
       User user = userMappper.queryByIdCard(idCard);
            if(user==null) {
                throw new Exception("用户不存在");
            }else {
            return user;}

        }


}
